package com.majun.config.standardfilter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * @author majun
 * @date 2024/11/30
 */
@Configuration
public class HttpReplacedFilterConfig {
    @Bean
    public FilterRegistrationBean authFilterRegistrationBean() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        //设置自定义的Filter
//        registration.setFilter(new HttpServletRequestReplacedFilter());
        registration.setFilter(new HttpReplacedFilter());
        //设置过滤路径
        registration.addUrlPatterns("/*");
        //设置过滤器名称
        registration.setName("HttpReplacedFilter");
        //设置过滤器顺序
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
        //设置初始化参数 这里不用
        //registration.addInitParameter("paramName", "paramValue");
        return registration;
    }
}